這是一系列關於 vim 操作方式的文章
主要的重點會著重於三個模式的基本操作
適合的對象為已經有基本 vim 使用經驗(知道 hjkl、i、<Esc>、:wq)
且具盲打能力的人
就讓我們從 . 開始吧
. 可以重復上次的修改
This is one.
This is two.
This is three.
x 可以刪除游標下的一個字元
試試看 x 吧
x
his is one.
This is two.
This is three.
.
is is one.
This is two.
This is three.
..
is one.
This is two.
This is three.
u 可以回復上次的修改
試試看 u 吧
u
s is one.
This is two.
This is three.
uuu
This is one.
This is two.
This is three.
dd 可以刪除一整行
試試看 dd 吧
dd
This is two.
This is three.
dd
This is three.
uu
This is one.
This is two.
This is three.
>G 可以將目前的行到最後一行都縮排一階
試試看 >G 吧
>G
This is one.
This is two.
This is three.
j 可以將游標往下移
j.
This is one.
This is two.
This is three.
關於修改,從進入 insert 模式後到退回 normal 模式,也算是一次修改,vim 會記錄所有的按鍵。
關於 . ,我們可以將之視為一個非常小的指令集(macro)。
想問
如果u(復原)過了頭
有辦法「重做」嗎?
可以哦~
u 是 undo ,直到最舊的改變
<C-r> 是 redo ,直到最新的改變
ps1:
<C-r> 指的是 Ctrl 鍵加上 r 鍵
ps2:
如果關掉 vim (:q) 的再開的話,就會通通被清掉了
就只有目前的狀態,沒有最新也沒有最舊
感謝你